/*
 * @(#)MonitoringStatisticsAction.java $version 2012-8-10
 * 
 * Copyright 2012 NADOSTAR Gruop. All rights Reserved.
 * NADOSTAR PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.nadostar.iims.monitoring.action;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.nadostar.extensions.util.DataMap;
import com.nadostar.iims.model.MonitoringParamModel;
import com.nadostar.iims.monitoring.bo.MonitoringBO;


/**
 * The Class MonitoringStatisticsAction.
 * 
 * @author Lixing
 *
 */
@Controller
@RequestMapping("/bbs/statistics")
public class MonitoringStatisticsAction {
	private static Log log = LogFactory.getLog(MonitoringStatisticsAction.class);
	
	@Autowired
	private MonitoringBO monitoringBO = null;
	
	@RequestMapping(method = RequestMethod.GET)
	public String execute()  {
		return "bbs/monitoringStatistics";
	}
	 
	 @RequestMapping(value = "/search", method = RequestMethod.GET)
	 public @ResponseBody Map<String, Object> search(
			 @RequestParam("startDate") String startDate,
			 @RequestParam("endDate") String endDate,
			 @RequestParam("productNo") String productNo,
			 @RequestParam("bbsTypeCd") String bbsTypeCd) {
		 Map<String, Object> jsonMap = new HashMap<String, Object>();
		 
		 log.debug("### MonitoringStatisticsAction.search...");
		 
		 MonitoringParamModel model = new MonitoringParamModel();
		 model.setStartDate(startDate);
		 model.setEndDate(endDate);
		 model.setProductNo(productNo);
		 model.setBbsTypeCd(bbsTypeCd);
		 
		 List<DataMap> monitoringList = monitoringBO.getMonitoringStatistics(model);
		 int total = monitoringList.size();
		 
		 jsonMap.put("total", total);
		 jsonMap.put("monitoringList", monitoringList);
		 return jsonMap;
	 }
}
